﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Hartley.Entities;
using Hartley.DTOs;

namespace Hartley.BusinessLogic
{
    public class HcFacade
    {
        HCPPADataContext hcDc;
        AdminManager adminManager;
        StudentManager studentManager;
        MemberManager memberManager;
        SportsManager sportsManager;
        FundManager fundManager;
        AthleticManager athleticManager;
        UserManager userManager;
        public HcFacade()
        {
            hcDc = new HCPPADataContext();
            adminManager = new AdminManager(hcDc);
            studentManager = new StudentManager(hcDc);
            memberManager = new MemberManager(hcDc);
            sportsManager = new SportsManager(hcDc);
            fundManager = new FundManager(hcDc);
            athleticManager = new AthleticManager(hcDc);
            userManager = new UserManager(hcDc);
        }

        public HcFacade(HCPPADataContext hcDc)
        {
            adminManager = new AdminManager(hcDc);
            studentManager = new StudentManager(hcDc);
            memberManager = new MemberManager(hcDc);
            sportsManager = new SportsManager(hcDc);
            fundManager = new FundManager(hcDc);
            athleticManager = new AthleticManager(hcDc);
            userManager = new UserManager(hcDc);
        }

        //Member Manager Related Methods

        public string saveMember(MemberDTO memberDTO)
        {
            try
            {

                return memberManager.SaveMember(memberDTO);
            }
            catch
            {
                throw;
            }
        }


        public string saveCommittee(CommitteeDTO committeeDTO)
        {
            try
            {
              return  memberManager.SaveCommittee(committeeDTO);
            }
            catch
            {
                throw;
            }
        }


        public string saveCommitteeMembers(CommitteeMemberDTO committeeMemberDTO)
        {
            try
            {
              return  memberManager.SaveCommiteeMembers(committeeMemberDTO);
            }
            catch
            {
                throw;
            }
        }


        public string saveMeeting(MeetingDTO meetingDTO)
        {
            try
            {
              return  memberManager.SaveMeeting(meetingDTO);
            }
            catch
            {
                throw;
            }
        }


        public string saveMinutes(MinutesDTO minutesDTO)
        {
            try
            {
              return  memberManager.SaveMinutes(minutesDTO);
            }
            catch
            {
                throw;
            }
        }


        public string saveSubCommittee(SubCommitteeDTO subCommitteeDTO)
        {
            try
            {
                return memberManager.SaveSubCommittee(subCommitteeDTO);
            }
            catch
            {
                throw;
            }
        }


        public string saveSubCommitteeMember(SubCommitteeMemberDTO subCommitteeMemberDTO)
        {
            try
            {
               return memberManager.SaveSubCommitteeMember(subCommitteeMemberDTO);
            }
            catch
            {
                throw;
            }
        }


        public String SaveRole(RoleDTO roleDTO)
        {
            try
            {
                return memberManager.SaveRole(roleDTO);
            }
            catch
            {
                throw;
            }
        }




        public List<MemberDTO> GetMembersbyId(Guid memberId)
        {
            return memberManager.GetMemberById(memberId);
        }
             


        public List<CommitteeDTO> GetCommitteeById(Guid committeeId)
        {
            return memberManager.GetCommitteeById(committeeId);

        }


        public List<SubCommitteeDTO> GetSubCommitteeById(Guid subCommitteeId)
        {
            return memberManager.GetSubCommitteeById(subCommitteeId);

        }


        public List<MeetingDTO> GetMeetingById(Guid meetingId)
        {
            return memberManager.GetMeetingById(meetingId);
        }

        public List<MeetingDTO> GetMeetingNameById(Guid meetingId)
        {
            return memberManager.GetAllMeetingNameById(meetingId);
        }


        public List<MinutesDTO> GetMinutesById(Guid minutesId)
        {
            return memberManager.GetMinutesById(minutesId);
        }
        
       
        



        public List<MemberDTO> GetAllMembers()
        {
            return memberManager.GetAllMember();

        }


        public List<CommitteeDTO> GetCommittees()
        {
            return memberManager.GetAllCommittee();

        }


        public List<SubCommitteeDTO> GetAllSubCommittees()
        {
            return memberManager.GetAllSubCommittee();
        }


        public List<MeetingDTO> GetAllMeetings()
        {
            return memberManager.GetAllMeetings();
        }

        public List<MinutesDTO> GetAllMinutes()
        {
            return memberManager.getAllMinutes();

        }
       








        public List<MeetingDTO> GetAllMeetingsOfCommittee(Guid committeeId)
        {
            return memberManager.GetAllMeetingsOfCommitteee(committeeId);
        }

        public List<MinutesDTO> GetAllMinutesByCommitteeId(Guid committeeId)
        {
            return memberManager.GetAllMinutesByCommitteeId(committeeId);
        }

        public List<MinutesDTO> GetAllMinutesOfMeeting(Guid meetingId)
        {
            return memberManager.GetAllMinutesOfMeeting(meetingId);
        }



        public List<SubCommitteeDTO> GetAllSubCommitteeByCommitteeId(Guid committeeId)
        {
            return memberManager.GetAllSubCommitteeByCommitteeId(committeeId);
        }

        public List<CommitteeMemberDTO> GetAllMemberOfCommitteeByCommitteeId(Guid committeeId)
        {
            return memberManager.GetAllMemberOfCommitteeByCommitteeId(committeeId);
        }

        public List<SubCommitteeMemberDTO> GetAllSubCommitteeMemberBySubCommitteeId(Guid subCommitteeId)
        {
            return memberManager.GetAllSubCommitteeMemberBySubCommitteeId(subCommitteeId);
        }

        public List<CommitteeMemberDTO> getAllRolseOfCommMember(Guid comMembrId)
        {
            return memberManager.getAllRolseOfCommMember(comMembrId);
        }

        public List<CommitteeMemberDTO> GetAllCommitteeMembers()
        {
            return memberManager.GetAllCommitteeMembers();
        }

        public List<CommitteeMemberDTO> getCommitteeMemberById(Guid comMembrId)
        {
            return memberManager.getCommitteeMemberById(comMembrId);
        }

        public List<RoleDTO> getAllRoles()
        {
            try
            {
                return memberManager.getAllRoles();
            }
            catch
            {
                throw;
            }
        }


        
        
        
        // User Manager Related Methods
        public string SaveUser(UserDTO userDTO)
        {
            try
            {
                return userManager.SaveUser(userDTO);
            }
            catch
            {
                throw;
            }
        }


        public String deleteRole(Guid roleId)
        {
            return memberManager.deleteRole(roleId);
        }

        //Admin Manager Related Methods


        public string SaveNews(NewsItemDTO newsItem)
        {
            return adminManager.SaveNews(newsItem);
        }

        public String deleteNewsById(Guid newsId)
        {
            try
            {
                return adminManager.deleteNewsById(newsId);
            }
            catch
            {
                throw;
            }
        }

        public List<NewsItemDTO> getLatestNewsByType(String type, int noOfLatestNews)
        {
            try
            {

                return adminManager.getLatestNewsByType(type,noOfLatestNews);
            }
            catch
            {
                throw;
            }
        }
        public string saveStaff(StaffDTO staffDTO)
        {
            try
            {
                return adminManager.SaveStaff(staffDTO);
            }
            catch
            {
                throw;
            }
        }








        public List<NewsItemDTO> GetNewsbyId(Guid newsId)
        {
            return adminManager.GetNewsById(newsId);
        }








        public List<NewsItemDTO> GetAllNews()
        {
            return adminManager.GetAllNews();
        }


        public List<StaffDTO> GetAllStaff()
        {
            return adminManager.GetAllStaff();
        }

        public List<StaffDTO> GetStaffById(Guid staffId)
        {
            return adminManager.GetStaffById(staffId);
        }



        //Student Manager Related Methods


        public void saveStudent(StudentDTO studentDTO)
        {
            studentManager.SaveStudent(studentDTO);
        }

        public string saveALResults(ALResultsDTO aLResultsDTO)
        {
            try
            {
                return studentManager.SaveALResults(aLResultsDTO);
            }
            catch
            {
                throw;
            }
        }

        public string saveOLResults(OLResultsDTO oLResultsDTO)
        {
            try
            {
                return studentManager.SaveOLResults(oLResultsDTO);
            }
            catch
            {
                throw;
            }
        }

        public string SavePrefectBatch(PrefectBatchDTO prefectBatchDTO)
        {
            try
            {

                return studentManager.SavePrefectBatch(prefectBatchDTO);
            }
            catch
            {
                throw;
            }
        }

        public string SavePrefects(PrefectDTO prefectDTO)
        {
            try
            {

                return studentManager.SavePrefects(prefectDTO);
            }
            catch
            {
                throw;
            }
        }




        public List<StudentDTO> GetStudents()
        {
            return studentManager.GetStudents();

        }

        public List<StudentDTO> GetStudentById(Guid studentId)
        {
            return studentManager.GetStudentById(studentId);

        }

        public List<StudentDTO> GetStudentByOLYear(string olYear)
        {
            return studentManager.GetStudentByOLYear(olYear);

        }

        public List<OLResultsDTO> GetAllOLevelResults()
        {
            return studentManager.GetAllOLevelResults();

        }

        public List<OLResultsDTO> GetOLevelResultByYear(int olevelResultYear)
        {
            return studentManager.GetOLevelResultByYear(olevelResultYear);

        }

        public List<ALResultsDTO> GetAllALevelResults()
        {
            return studentManager.GetAllALevelResults();

        }

        public List<ALResultsDTO> GetALevelResultByYear(int alevelResultYear)
        {
            return studentManager.GetALevelResultByYear(alevelResultYear);

        }

        public List<PrefectBatchDTO> GetAllPrefectBatches()
        {
            try
            {
                return studentManager.GetAllPrefectBatches();
            }
            catch
            {
                throw;
            }

        }

        public List<PrefectDTO> GetPrefectsByPrefectBatchId(Guid prefectBatchId)
        {
            try
            {
                return studentManager.GetPrefectsByPrefectBatchId(prefectBatchId);
            }
            catch
            {
                throw;
            }

        }


        public List<PrefectDTO> GetAllPrefects()
        {
            try
            {
                return studentManager.GetAllPrefects();
            }
            catch
            {
                throw;
            }

        }

        public List<PrefectBatchDTO> GetPrefectBatchById(Guid prefectBatchId)
        {
            try
            {
                return studentManager.GetPrefectBatchById(prefectBatchId);
            }
            catch
            {
                throw;
            }

        }


        public List<PrefectDTO> GetPrefectsById(Guid prefectId)
        {
            try
            {
                return studentManager.GetPrefectsById(prefectId);
            }
            catch
            {
                throw;
            }

        }


        //Athletic Manager Related Methods


        public string saveAthleticEvent(AthleticEventDTO athleticEvent)
        {
            try
            {
                return athleticManager.SaveAthleticEvent(athleticEvent);
            }
            catch (Exception e)
            {
                throw;
            }

        }


        public void saveAthleticData(AthleticDataDTO athleticData)
        {
            athleticManager.SaveAthleticData(athleticData);
        }


        public void SaveAthleticRecord(AthleticRecordDTO athleticRecordDTO)
        {
            athleticManager.SaveAthleticRecord(athleticRecordDTO);
        }
        

        public List<AthleticEventDTO> GetAthleticEventById(Guid athleticEventId)
        {
            return athleticManager.GetAthleticEventById(athleticEventId);
        }






        public List<AthleticEventDTO> GetAthleticEvents()
        {
            return athleticManager.GetAthleticEvents();

        }
        public List<AthleticDataDTO> GetAllAthleticData()
        {
            return athleticManager.GetAllAthleticData();
        }


        public List<AthleticDataDTO> GetAllYrsOfAthleticData()
        {
            return athleticManager.GetAllYrsOfAthleticData();

        }

        public List<AthleticDataDTO> GetAllLevelsOfAthleticData()
        {
            return athleticManager.GetAllLevelsOfAthleticData();
        }

        public List<AthleticEventDTO> GetAllAgeDivisionAndEventCategoryByYear(int yr)
        {
            return athleticManager.GetAllAgeDivisionAndEventCategoryByYear(yr);
        }


        public List<AthleticEventDTO> GetAllAgeDivisionAndEventCategoryFromAthleticDataList(List<AthleticDataDTO> athleticData)
        {
            return athleticManager.GetAllAgeDivisionAndEventCategoryFromAthleticDataList(athleticData);
        }


        public List<Guid> GetAthleticIdByAgeDivisionAndEventCategory(string ageDivision, string eventCategory)
        {
            return athleticManager.GetAthleticIdByAgeDivisionAndEventCategory(ageDivision,eventCategory);
        }


        public List<AthleticDataDTO> GetAthleticDataByYearByLevelByAgeGruopByEvent(int year, string levelName, string ageDivision, string eventCategory)
        {
            return athleticManager.GetAthleticDataByYearByLevelByAgeGruopByEvent(year,levelName,ageDivision,eventCategory);
        }

       public List<AthleticDataDTO> GetAllAthleticDataOfStudent(Guid studentId)
        {
            return athleticManager.GetAllAthleticDataOfStudent(studentId);
        }

       //public bool isRelay(Guid athleticEventId)
       //{
       //    return athleticManager.isRelay(athleticEventId);
       //}

        //Sports Manager Related Methods



        public void saveTeam(TeamDTO teamDTO)
        {
            sportsManager.SaveTeam(teamDTO);
        }


        public void saveTeamMember(TeamMemberDTO teamMemberDTO)
        {
            sportsManager.SaveTeamMembers(teamMemberDTO);
        }


        public string saveMatch(MatchDTO matchDTO)
        {
            try
            {
              return  sportsManager.SaveMatch(matchDTO);
            }
            catch
            {
                throw;
            }
        }

        public List<TeamDTO> GetAllTeams()
        {
            return sportsManager.GetAllTeams();
        }

        public List<TeamDTO> GetTeamById(Guid teamId)
        {
            return sportsManager.GetTeamById(teamId);
        }


        public List<TeamDTO> GetTeamByGameTypeByYearByAgeGruop(string gameType, int year, string ageDivision)
        {
            return sportsManager.GetTeamByGameTypeByYearByAgeGruop(gameType,year,ageDivision);
        }


        public List<TeamMemberDTO> GetTeamMemberByTeamId(Guid teamId)
        {
            return sportsManager.GetTeamMemberByTeamId(teamId);
        }


        public List<MatchDTO> GetAllMatchesByTeamId(Guid teamId)
        {
            return sportsManager.GetAllMatchesByTeamId(teamId);
        }

        public List<MatchDTO> GetMatchByMatchId(Guid matchId)
        {
            return sportsManager.GetMatchByMatchId(matchId);
        }

        public List<MatchDTO> GetAllMatches()
        {
            return sportsManager.GetAllMatches();
        }

        public List<TeamMemberDTO> GetAllTeamParticipationOfTeamMemberByTeamMemberId(Guid teamMemberId)
        {
            return sportsManager.GetAllTeamParticipationOfTeamMemberByTeamMemberId(teamMemberId);
        }

        //Fund Manager Related Methods


        public string saveFund(FundDTO fundDTO)
        {
            try
            {

                return fundManager.SaveFund(fundDTO);
            }
            catch
            {
                throw;
            }
        }


        public string SaveScholarShip(ScholarshipDTO scholarshipDTO)
        {
            try
            {

                return fundManager.SaveScholarShip(scholarshipDTO);
            }
            catch
            {
                throw;
            }
        }

        public string SaveScholarShipData(ScholarshipDataDTO scholarshipDataDTO)
        {
            try
            {

                return fundManager.SaveScholarShipData(scholarshipDataDTO);
            }
            catch
            {
                throw;
            }
        }

        public List<ScholarshipDTO> GetAllScholarShip()
        {
            try
            {

                return fundManager.GetAllScholarShip();
            }
            catch
            {
                throw;
            }
        }


        public List<ScholarshipDataDTO> GetAllScholarShipData()
        {
            try
            {

                return fundManager.GetAllScholarShipData();
            }
            catch
            {
                throw;
            }
        }

        public List<ScholarshipDTO> GetScholarShipById(Guid scholarshipId)
        {
            try
            {

                return fundManager.GetScholarShipById(scholarshipId);
            }
            catch
            {
                throw;
            }
        }

        public List<ScholarshipDataDTO> GetAllScholarShipDataByScholarShipId(Guid scholarshipId)
        {
            try
            {

                return fundManager.GetAllScholarShipDataByScholarShipId(scholarshipId);
            }
            catch
            {
                throw;
            }
        }


        public List<ScholarshipDataDTO> GetAllScholarShipDataOfStudent(Guid studentId)
        {
            try
            {

                return fundManager.GetAllScholarShipDataOfStudent(studentId);
            }
            catch
            {
                throw;
            }
        }

        public List<FundDTO> GetFundbyId(Guid fundId)
        {
            return fundManager.GetFundById(fundId);
        }



        public List<FundDTO> GetAllFund()
        {
            return fundManager.GetAllFund();
        }



        public void deleteFundById(Guid fundId)
        {
             fundManager.deleteFundById(fundId);
        }

      

        

        

        

       

        
        

       

       

       

       
       

       

        


        
       

       
        //public bool validateLogin(string userName,string password)
        //{
            //return memberManager.validateLogin(userName, password);
        //}
        public bool checkAvailabilityOfUserName(string userName)
        {
            return memberManager.checkAvailabilityOfUserName(userName);
        }

    }
}
